﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="menetlusinfo_v3_hoiatus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MenetlusinfoV3Hoiatus))]
    public class MenetlusinfoV3HoiatusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMenetlusinfoV3Hoiatus clazz;
        
        public MenetlusinfoV3HoiatusSerializer(IMenetlusinfoV3Hoiatus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("hoiat_numb");
            if (clazz.HoiatNumb!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatNumb))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : HoiatNumb");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevikukande_id");
            if (clazz.PaevikukandeId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PaevikukandeId))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PaevikukandeId");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevikukande_id_vana");
            if (clazz.PaevikukandeIdVana!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PaevikukandeIdVana))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PaevikukandeIdVana");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiat_kuup");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.HoiatKuup))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiat_nimetus");
            if (clazz.HoiatNimetus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatNimetus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : HoiatNimetus");
            }
            Writer.WriteEndElement();
            if (clazz.HoiatTekst!=null) {
                Writer.WriteStartElement("hoiat_tekst");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatTekst))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="hoiat_numb") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>hoiat_numb");
                }
                clazz.HoiatNumb = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiat_numb")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_hoiatus>hoiat_numb", Reader.LocalName);
            }
            if (Reader.LocalName=="paevikukande_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>paevikukande_id");
                }
                clazz.PaevikukandeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("paevikukande_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_hoiatus>paevikukande_id", Reader.LocalName);
            }
            if (Reader.LocalName=="paevikukande_id_vana") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>paevikukande_id_vana");
                }
                clazz.PaevikukandeIdVana = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("paevikukande_id_vana")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_hoiatus>paevikukande_id_vana", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiat_kuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>hoiat_kuup");
                }
                clazz.HoiatKuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("hoiat_kuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_hoiatus>hoiat_kuup", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiat_nimetus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>hoiat_nimetus");
                }
                clazz.HoiatNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiat_nimetus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_hoiatus>hoiat_nimetus", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiat_tekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_hoiatus>hoiat_tekst");
                }
                clazz.HoiatTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiat_tekst")).Value;
            }
        }
    }
}
